/*
 * @Author: 杰编程 2306248989@qq.com
 * @Date: 2023-07-21 16:03:00
 * @LastEditors: 杰编程 2306248989@qq.com
 * @LastEditTime: 2023-07-21 17:27:49
 * @FilePath: /lesson17/mykill.cc
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include <iostream>

using namespace std;

#include <cstring>

#include <sys/types.h>
#include <signal.h>

void Usage(char *str)
{
    printf("%s 信号编码 进程pid\n", str);
}

int main(int argc, char *argv[])
{
    if (argc != 3)
    {
        Usage(argv[0]);
    }
    else
    {
        int pid = atoi(argv[2]);
        int sig = atoi(argv[1] + 1);
        cout << "pid:" << pid << "; sig:" << sig << endl;
        int ret = kill(pid, sig);
        if (ret != 0)
        {
            perror("kill:");
        }
    }
    return 0;
}